<?php

require('init.php');

$id= $_REQUEST['pid'];

if($_REQUEST['b'] == '1')
{
	$prob = $DB->q('TUPLE SELECT * FROM set_problems WHERE probid = %s',$id);

}elseif($_REQUEST['b'] == '2')
{
	$query = "SELECT * FROM set_problems WHERE probid ='$id'";
	//mysql_select_db("domjudge2" , $conn_db2);
	$res = mysql_query($query ,$conn_db2);
	if($res)
	{
		$prob = mysql_fetch_array($res, MYSQL_BOTH);
		//print_r($prob);
	}else{
		throw new RuntimeException("SQL syntax-error, ". "Error " .
				mysql_error($conn_db2) . ", query: '$query'");
	}
}
	

header("Content-type: ".$prob['tipo']);
header("Cache-Control: no-cache");
header("Pragma: no-cache");
header("Content-Disposition: inline;filename='".$prob['nombre']."'");
header("Content-length: ".strlen($prob['contenido']));
echo $prob['contenido'];


?>
